package com.zahb.qadx.ui.fragment;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.zahb.qadx.R;
import com.zahb.qadx.model.Curriculum;
import com.zahb.qadx.model.MainFunc1;
import com.zahb.qadx.model.MainFunc2;
import com.zahb.qadx.ui.activity.CurriculumDetailsActivity;
import com.zahb.qadx.ui.activity.CurriculumListActivity;

/**
 * Created by Zdw on 2020/10/13 14:11
 * 推荐课程
 */
public class CurriculaFragment extends VideosFragment {

    static final String TAG = "CurriculaFragment";

    static CurriculaFragment newInstance(MainFunc1 mainFunc1) {
        Bundle args = new Bundle();
        args.putSerializable("data", mainFunc1);
        CurriculaFragment fragment = new CurriculaFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mTvTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
                R.drawable.ic_home_curricula, 0, 0, 0);
    }

    @Override
    protected void seeMore() {
        MainFunc1 mainFunc1 = (MainFunc1) mArguments.getSerializable("data");
        if (mainFunc1 != null) {
            CurriculumListActivity.actionStart(getContext(), mainFunc1.getSourceId());
        }
    }

    @Override
    public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        MainFunc2 mainFunc2 = mVideosAdapter.getItem(position);
        Curriculum curriculum = new Curriculum(mainFunc2.getSourceId(), mainFunc2.getTitle(), mainFunc2.getSubTitle(),
                mainFunc2.getIcon(), "", "");
        CurriculumDetailsActivity.actionStart(getContext(), curriculum, CurriculumDetailsActivity.TYPE_FROM_HOME);
    }
}
